package cc.mrbird.merchant;

import cc.mrbird.common.annotation.Log;
import cc.mrbird.common.controller.BaseController;
import cc.mrbird.common.domain.QueryRequest;
import cc.mrbird.common.domain.ResponseBo;
import cc.mrbird.common.util.FileUtils;
import cc.mrbird.job.domain.JobLog;
import cc.mrbird.job.domain.Trans;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

public class MerchatnController extends BaseController {

    @Log("获取调度日志信息")
    @RequestMapping("merQuery")
    @RequiresPermissions("merchant:select")
    public String index() {
        return "merchant/merQuery/merchantQuery";
    }

  /*  @RequestMapping("mer/list")
    @ResponseBody
    public Map<String, Object> jobLogList(QueryRequest request, JobLog log) {
        PageHelper.startPage(request.getPageNum(), request.getPageSize());
        Trans trans = new Trans();
        List<Trans> list = this.transService.findTransWithSel(trans);
        PageInfo<Trans> pageInfo = new PageInfo<>(list);
        return getDataTable(pageInfo);
    }


    @RequestMapping("trans/excel")
    @ResponseBody
    public ResponseBo transExcel(Trans trans) {
        try {
            List<Trans> list = this.transService.findTransWithSel(trans);
            return FileUtils.createExcelByPOIKit("交易明细表", list, Trans.class);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseBo.error("导出Excel失败，请联系网站管理员！");
        }
    }

    @RequestMapping("trans/csv")
    @ResponseBody
    public ResponseBo transCsv(Trans trans) {
        try {
            List<Trans> list = this.transService.findTransWithSel(trans);
            return FileUtils.createCsv("交易明细表", list, Trans.class);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseBo.error("导出Csv失败，请联系网站管理员！");
        }
    }*/



}
